# Maintainer: Giovanni Scafora <giovanni@archlinux.org>
# Maintainer: Maxime Gauduin <alucryd@archlinux.org>
# Contributor: xduugu <xduugu@gmx.com>

pkgbase=mkvtoolnix
pkgname=('mkvtoolnix-cli' 'mkvtoolnix-gui')
pkgver=27.0.0
pkgrel=1
pkgdesc='Set of tools to create, edit and inspect Matroska files'
arch=('x86_64')
url='https://www.bunkus.org/videotools/mkvtoolnix/'
license=('GPL')
makedepends=(
  'boost' 'boost-libs' 'cmark' 'docbook-xsl' 'file' 'flac' 'git' 'libebml'
  'libmatroska' 'libogg' 'libvorbis' 'qt5-multimedia' 'ruby-rake' 'zlib'
)
source=("git+https://gitlab.com/mbunkus/mkvtoolnix.git#tag=release-${pkgver}")
sha256sums=('SKIP')

prepare() {
  cd mkvtoolnix

  ./autogen.sh
}

build() {
  cd mkvtoolnix

  ./configure \
    --prefix='/usr' \
    --disable-qt
  rake apps:mkvinfo $MAKEFLAGS
  mv src/mkvinfo{,-cli}

  ./configure \
    --prefix='/usr' \
    --disable-update-check
  rake $MAKEFLAGS
}

package_mkvtoolnix-cli() {
  depends=(
    'boost-libs' 'file' 'flac' 'gcc-libs' 'glibc' 'libogg' 'zlib'
    'libebml.so' 'libmatroska.so' 'libvorbis.so'
  )

  cd mkvtoolnix

  rake DESTDIR="${pkgdir}" install
  install -m 755 src/mkvinfo-cli "${pkgdir}"/usr/bin/mkvinfo
  rm -rf "${pkgdir}"/usr/share/{applications,icons,metainfo,mime,mkvtoolnix}
  find "${pkgdir}" -name mkvtoolnix-gui* -delete
}

package_mkvtoolnix-gui() {
  depends=(
    'cmark' 'hicolor-icon-theme' 'mkvtoolnix-cli' 'qt5-base' 'qt5-multimedia'
  )

  cd mkvtoolnix

  rake DESTDIR="${pkgdir}" install
  rm -rf "${pkgdir}"/usr/share/locale
  for t in mkv{extract,info,merge,propedit}; do
    find "${pkgdir}" -name $t* -delete
  done
}

# vim: ts=2 sw=2 et:
